package com.hxzy;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 网络爬虫
 */
public class HtmlParse {
    public static void main(String[] args) throws IOException {

        String chinaz = "https://ip.chinaz.com/";
        Document document = Jsoup.connect(chinaz).get();

        Elements elements = document.selectXpath("//*[@id=\"leftinfo\"]/div[3]/div[2]/div[2]");
        //再查询<span>
        Elements spanElements = elements.select("span");
        String ip=spanElements.get(0).text();
        Elements emList = spanElements.get(spanElements.size() - 1).select("em");
        String addresss=emList.get(0).text();
        String st=addresss.split(" ")[0];

        System.out.println(ip);
        System.out.println(addresss);
        System.out.println(st);


    }
}
